<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="${pageContext.request.contextPath}/editor/jquery/uploadify3.2.1/uploadify.css" type="text/css"/>
<link href="${pageContext.request.contextPath}/editor/jquery/pagination/pagination.css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<style type="text/css" media="all">
ul,li{margin:0; padding:0;list-style:none;float:left;margin-left: 20px;} 
</style>


</head>

<body>

<jsp:include page="../user/top.jsp"></jsp:include>
<jsp:include page="../user/left.jsp"></jsp:include>
<div style="position:absolute;left:200px;top:50px;">

  <%-- <span>上传完工凭证1：</span>
      用来作为文件队列区域 --不显示
  <div id="uploadfileQueue">
  </div>--%>
  <div style="margin-left: 83px;color: blue;">
      <input type="file" id="tupian8" name="fileData"/>  
  </div>
  <div id="examineTable" style="height: 200px;" > 
  </div><br/><br/>
    <center>
	<table>
		 <tr>
		      <td>
		          <div id="pagination_1"></div>
		      </td>
		      <td style="padding-bottom:8px;">共<span id="pages_1" style="color: blue;"></span>页/<span id="totalRecords_1" style="color: blue;"></span>条数据</td>
		</tr>
	 </table>
	</center>
  <%--需要显示上传按钮    'auto':true,--%>
  <%--<a href="javascript:$('#tupian8').uploadify('upload','*')">开始上传</a>--%>
  <%--<input type="hidden" id="oddJpga" name="oddJpga"/>
  <div id="show88" style="margin:0 0 10px 80px">
  <img id="show8" src="" style="border:1px #ddd solid;max-width:100px;width: 100px"/></div>--%>	               	
</div>
<script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/uploadify3.2.1/jquery.uploadify.js"></script>
 <script type="text/javascript" src="${pageContext.request.contextPath}/editor/jquery/pagination/jquery.pagination.js"></script>
 
 <script type="text/javascript">
	$(function(){
		var maxFileSize = 3 * 1024;
		$("#tupian8").uploadify({
			'debug' 	: false,
			'auto'		:true,
			'buttonText':'上传图片...',
			'swf'		: "${pageContext.request.contextPath}/editor/jquery/uploadify3.2.1/uploadify.swf",
			'queueID'	:'uploadfileQueue',
			'uploader'	:'upload2.action?username=${sessionScope.username}',
			'progressData' :'speed',
			'width'		:'126',
	        'height'	:'24',
	        'multi'		:true,
	        'fileObjName':'fileData',
	        'fileTypeDesc':'支持的格式：',
	        'fileTypeExts':'*.jpg;*.jpge;*.gif;*.png',
	        'fileSizeLimit': maxFileSize,
	        'removeTimeout':1,
	        'onSelectError':function(file, errorCode, errorMsg){  
	            switch(errorCode) {  
	                case -100:  
	                    alert("上传的文件数量已经超出系统限制的"+$('#tupian8').uploadify('settings','queueSizeLimit')+"个文件！");  
	                    break;  
	                case -110:  
	                    alert("文件 ["+file.name+"] 大小超出系统限制的"+$('#tupian8').uploadify('settings','fileSizeLimit')+"k大小！");  
	                    break;  
	                case -120:  
	                    alert("文件 ["+file.name+"] 大小异常！");  
	                    break;  
	                case -130:  
	                    alert("文件 ["+file.name+"] 类型不正确！");  
	                    break;  
	            }  
	        },
	        'onFallback':function(){
	            alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");
	        },
	        'onSelect': function(file){
	        	$("#file88").text("正在上传...");
	        },
	        'onUploadSuccess':function(file, data, response){
	        	//解析JSON字符串为JSon数据格式
	        	var json = eval("(" + data + ")");
	        	if(json.savephoto=="save"){
	        		window.location.href="${pageContext.request.contextPath}/page_myphoto_mytv.action";
	        	}
		    }
		});
		list_che(0);
		function list_che(pageNo){
			$.ajax({
				   type: "POST",
				   url: "user_photo",
				   data:{"pageNo":(pageNo + 1)},
				   success:function(data){
					   $("#totalRecords_1").text(data.total);
	  				   $("#pages_1").html(data.pages);
	  				   $("#examineTable").empty();
	  				   $.each(data.photos,function(i,val){
	  					 var examineTable = "<li>"+
				           "<img src="+val.smallphoto+">"+
			               "</li>";
				           $("#examineTable").append(examineTable);
	  					 
	  					});
	  				 $("#pagination_1").pagination(data.total, {   
	  	 				callback: list_che,   
	  	 			    prev_text: '上一页',   
	  	 			    next_text: '下一页',
	  	 			    items_per_page:5,  
	  	 			    num_display_entries:10,  
	  	 			    current_page:pageNo,   
	  	 			    num_edge_entries:5, 
	  	 			    maxentries: data.total, 
	  	 			    link_to: "javascript:void(0)"
	  	 			});
				   }
			});  
		}
    })
 </script>   
</body>
</html>